<?php

namespace Yz\modules\Generic;

class Template_ActionsMenu
    extends \Yz_Template_Native
    implements \Yz_Template_Interface
{

    /**
     *
     */
    protected function doRender()
    {
        debug();
        $this->createMenu();
        if (isset($this->value['item'])) {
            $this->createMenuForItem($this->value['item']);
        }
        return parent::doRender();
    }


    /**
     *
     */
    protected function createMenu()
    {
        debug();
        $val =& $this->value;
        $baseURI = $val['webPrefix'] . $val['YzAdmin'] . $val['YzModule'] . '/';
        $menu = array();
        $menu[] = new \Yz_Hash(array(
            'href' => $baseURI . 'default',
            'title' => $this->translate('#Controller_Default'),
            ));
        $menu[] = new \Yz_Hash(array(
            'href' => $baseURI . 'list',
            'title' => $this->translate('#Controller_List'),
            ));
        $val['menu'] = $menu;
        return $this;
    }

    /**
     *
     */
    protected function createMenuForItem($item)
    {
        debug();
        $id = $item->id;
        $val =& $this->value;
        $baseURI = $val['webPrefix'] . $val['YzAdmin'] . $val['YzModule'] . '/';
        $menu =& $this->value['menu'];
        $menu[] = new \Yz_Hash(array(
            'href' => $baseURI . "entry/{$id}",
            'title' => $this->translate('#Controller_Entry'),
            ));
        $menu[] = new \Yz_Hash(array(
            'href' => $baseURI . "edit/{$id}",
            'title' => $this->translate('#Controller_Edit'),
            ));
        return $this;
    }

}
